//------------------------------------------------------------------------------
//  VertexElement.cpp
//  (C) 2009 xoyojank
//------------------------------------------------------------------------------
#include "StdEddy.h"
#include "Graphics/VertexElement.h"

//------------------------------------------------------------------------------
namespace Eddy
{

//------------------------------------------------------------------------------
const char*
VertexElement::GetGLAttrName(VertexElement::Semantic semantic, IndexT semanticIndex)
{
    static const char* AttrNames[] =
    {
        "a_position",
        "a_normal",
        "a_diffuse",
        "a_specular",
        "a_texcoord",
    };
    if (TexCoord != semantic)
    {
        return AttrNames[semantic];
    }
    else
    {
        static char buffer[32];
        sprintf_s(buffer, sizeof(buffer), "%s%u", AttrNames[semantic], semanticIndex);
        return buffer;
    }
}

//------------------------------------------------------------------------------
GLenum
VertexElement::GetGLDataType() const
{
    switch (this->format)
    {
    case Float:
    case Float2:
    case Float3:
    case Float4:
        return GL_FLOAT;
    case UByte4N:
        return GL_UNSIGNED_BYTE;
    default:
        return 0;
    }
}

//------------------------------------------------------------------------------
GLboolean
VertexElement::IsNormalized() const
{
    switch (this->format)
    {
    case UByte4N:
        return GL_TRUE;
    default:
        return GL_FALSE;
    }
}
}// Eddy